package name.fowler.refactoring.simplestore;

import static org.junit.Assert.*;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;

import java.util.Arrays;
import java.util.Collection;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.junit.runners.Parameterized.Parameters;

public class RentalBuilder {
	
	public static final String DEDAULT_MOVIE_NAME = "testMovie";
	
	String movieName = DEDAULT_MOVIE_NAME;
	
	int daysRental = 0;
	boolean needAdditionalPoints;
	double amount;
	
	public RentalBuilder withAmount(double amount){
		this.amount = amount;
		return this;
	}
	
	public RentalBuilder withMovieName(String movieName){
		this.movieName = movieName;
		return this;
	}
	
	public RentalBuilder withDaysRental(int daysRental){
		this.daysRental = daysRental;
		return this;
	}
	
	public RentalBuilder withNeedAdditionalPoints(boolean needAdditionalPoints){
		this.needAdditionalPoints = needAdditionalPoints;
		return this;
	}
	
	public Rental build() {
		Movie stubMovie = mock(Movie.class);
		when(stubMovie.getTitle()).thenReturn(movieName);
		when(stubMovie.getPriceCode()).thenReturn(PriceCodes.Regular);

		Rental stubRental = mock(Rental.class);
		when(stubRental.getMovie()).thenReturn(stubMovie);
		when(stubRental.getDaysRented()).thenReturn(daysRental);
		when(stubRental.needAdditionalFrequentPoints()).thenReturn(needAdditionalPoints);
		when(stubRental.getAmount()).thenReturn(amount);
		return stubRental;
	}
}
